﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Logging
{
    public static class Helper
    {
        public static Stream OpenLogFileStream(FileMode mode, FileAccess access, FileShare share)
        {
            var file = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
            var fs = file.OpenFile("log.txt", mode, access, share);
            return fs;
        }

        public static bool IsLogExists()
        {
            var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
            return store.FileExists("log.txt");
        }

        public static void ClearLog()
        {
            var file = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
            file.Remove();
        }

        public static void CreateDb()
        {
            using (var db = new DataBase())
            {
                if (!db.DatabaseExists())
                {
                    db.CreateDatabase();
                }
            }
        }
    }
}
